<?php

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Support\Facades\Auth;
class StoreUserRequest extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     */
    public function authorize(): bool
    {
        return Auth::id()==1;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
     */
    public function rules(): array
    {
        return [
            "department_id"=>"required",
            "name" => "required|unique:users,name",
            "mobile" => "required|unique:users,mobile",
        ];
    }
    public function messages()
    {
        return [
            "department_id.required"=>"部门不能为空",
            'name.required' => '用户名不能为空',
            'name.unique' => '用户名已存在',
            'mobile.required' => '手机号不能为空',
            'mobile.unique' => '手机号已存在',
        ];
    }
}
